/**
    ATClab - scriptable Air Traffic Control simulations.
    Copyright (C) 2010 openatclab@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef __ATC_LIST_BOX_HDR__
#define __ATC_LIST_BOX_HDR__

#include <q3listbox.h>
#include <qdialog.h>
//Added by qt3to4:
#include <QKeyEvent>
#include <QLabel>

//
// Qt
//
class QLabel;
class QLineEdit;
class QPushButton;


namespace atc{

	//
	// atc::
	//
	class AircraftAgent;


	//
	// atc::ListBox
	//
	class ListBox : public QDialog {
		Q_OBJECT;

	public:
		ListBox( QWidget * = 0, const char * = 0 );
		~ListBox();

	public:
		virtual void set_aircraft( AircraftAgent *ac ) { _agent = ac; }
		void  clear_aircraft() { _agent = 0; }

	public:
		virtual const char* type() const = 0;

		const char* aircraft_id() const;
		double value() const;

	protected: // QWidget
		virtual void keyPressEvent( QKeyEvent * );

	private slots:
		virtual void selection_event( const QString & ) = 0;

	protected:
		AircraftAgent *_agent;
		Q3ListBox      *_list;
		int            _value;

	};


	/*!
	 *
	 */
	class CFLSelector : public ListBox {
		Q_OBJECT
	
	public:
		CFLSelector( QWidget *w = 0, const char *n = 0 )
			  : ListBox( w, n ) {}
		~CFLSelector() {}

	public: // virtual
		void set_aircraft( AircraftAgent * );
		const char* type() const { return "cleared_flight_level"; }

	private slots:
		void selection_event( const QString & );

	};


	/*!
	 *
	 */
	class VelocitySelector : public atc::ListBox {
		Q_OBJECT
	public:
		VelocitySelector( QWidget *w = 0, const char *n = 0 )
			  : ListBox( w, n ) {}
		~VelocitySelector() {}

	public:
		void set_aircraft( AircraftAgent * );
		const char* type() const { return "cleared_airspeed"; }

	private slots:
		void selection_event( const QString & );

	};

	//
	// atc::HeadingSelector
	//
	class HeadingSelector : public ListBox {
		Q_OBJECT

	public:
		HeadingSelector( QWidget * = 0, const char * = 0 );
		~HeadingSelector();

	public:
		void set_aircraft( AircraftAgent * );
		const char* type() const { return "heading_selector"; }

	private slots:
		void selection_event( const QString & );

	};

	//
	// atc::RequirementSelector
	//
	class RequirementSelector : public QDialog {
		Q_OBJECT

	public:
		RequirementSelector( QWidget * );
		~RequirementSelector();

	public:
		void set_aircraft( AircraftAgent * );

	public:
		const char* aircraft_id() const;
		double level   () const;
		double distance() const;

	protected slots:
		void accept();


	private:
		AircraftAgent *_ac;

		QLineEdit   *_level;
		QLineEdit   *_distance;
		QPushButton *_ok;
		QPushButton *_cancel;

	};

};

#endif
